<template>
<view class="mine_view">
    <view class="container">
        {{user.name}}
    </view>
    <u-button
        type="error"
        @click="onQuit">
        退出
    </u-button>
</view>
</template>

<script>
export default {  //个人中心
    computed:{
        user:{  //全局的用户信息
            get(){
                return this.$store.state.user;
            },
            set(newValue){
                this.$store.commit('setUser',newValue);
            },
        },
    },
    methods:{
        onQuit(){  //退出登陆
            this.user = {};  //清空用户信息
            uni.reLaunch({  //跳转到登陆页面（不保留之前页面）
                url: '/pages/login/index',
            });
        },
    },
}
</script>

<style lang="scss" scoped>
.mine_view{
	display: flex;
	flex-direction: column;
	justify-content:flex-start;
	align-items: center;
    width: 100%;
    padding: 60rpx;
    box-sizing: border-box;
    .container{
        width: 100%;
    }
    .u-button{
        width: 100%;
        margin-top: 30rpx;
    }
}
</style>
